package com.ly.mpayment.rest.recharge;

import java.util.Iterator;
import java.util.List;
import java.util.NavigableSet;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ConcurrentSkipListMap;
import java.util.concurrent.LinkedBlockingQueue;

import com.ly.mpayment.core.util.DateUtils;
import com.ly.mpayment.persist.entity.*;
import com.ly.mpayment.persist.service.callorder.ICallOrderService;
import com.ly.mpayment.persist.service.timer.ProductTimerService;
import com.ly.mpayment.persist.service.timer.ProductTimerUpService;
import com.ly.mpayment.rest.system.entity.ManualRechargeOrder;
import com.ly.mpayment.rest.up.anchang.AnChangRest;
import com.ly.mpayment.rest.up.chenhan.ChenHanRest;
import com.ly.mpayment.rest.up.chinaunicom.ChinaUnicomRest;
import com.ly.mpayment.rest.up.dongye.DongYeRest;
import com.ly.mpayment.rest.up.fanxin.FanXinRest;
import com.ly.mpayment.rest.up.feizhidu.FeiZhiDuRest;
import com.ly.mpayment.rest.up.fengniu.FengNiuRest;
import com.ly.mpayment.rest.up.fulu.FuLuRest;
import com.ly.mpayment.rest.up.guangmu.GuangMuRest;
import com.ly.mpayment.rest.up.guochuang.GuoChuangRest;
import com.ly.mpayment.rest.up.hebao.HeBaoRest;
import com.ly.mpayment.rest.up.honglu.HongLuRest;
import com.ly.mpayment.rest.up.hongshi.HongShiRest;
import com.ly.mpayment.rest.up.huarongxunfang.HuaRongRest;
import com.ly.mpayment.rest.up.huisutong.HuiSuTongRest;
import com.ly.mpayment.rest.up.jiamiduo.JiaMiDuoRest;
import com.ly.mpayment.rest.up.jiangren.JiangRenRest;
import com.ly.mpayment.rest.up.jiuya.JiuYaRest;
import com.ly.mpayment.rest.up.juesheng.JueShengRest;
import com.ly.mpayment.rest.up.longzhang.LongZhangRest;
import com.ly.mpayment.rest.up.maiyuan.MaiYuanRest;
import com.ly.mpayment.rest.up.maiyuan2.MaiYuan2Rest;
import com.ly.mpayment.rest.up.maiyuanhf.MaiYuanhfRest;
import com.ly.mpayment.rest.up.masike.MaSiKeRest;
import com.ly.mpayment.rest.up.meijia.MeiJiaRest;
import com.ly.mpayment.rest.up.napi.NaPiRest;
import com.ly.mpayment.rest.up.qgliantong.QuanGuoLtRest;
import com.ly.mpayment.rest.up.qingchi.QingChiRest;
import com.ly.mpayment.rest.up.qinghaiyd.QingHaiYd;
import com.ly.mpayment.rest.up.renxingkeji.RenXingRest;
import com.ly.mpayment.rest.up.sanchongmao.SanChongMaoRest;
import com.ly.mpayment.rest.up.shuoruan.ShouRuanRest;
import com.ly.mpayment.rest.up.shuwang.ShuWangRest;
import com.ly.mpayment.rest.up.suhu.SuHuRest;
import com.ly.mpayment.rest.up.tianzhong.TianZhongRest;
import com.ly.mpayment.rest.up.wanlifanghe.WanLiFangHeRest;
import com.ly.mpayment.rest.up.wswpay.WswpayRest;
import com.ly.mpayment.rest.up.xinjin.XinJinRest;
import com.ly.mpayment.rest.up.xuanjie.XuanJieRest;
import com.ly.mpayment.rest.up.yezhikeji.YezhikejiRest;
import com.ly.mpayment.rest.up.yiche.YiTongDaRest;
import com.ly.mpayment.rest.up.yingyou.YingYouRest;
import com.ly.mpayment.rest.up.yishuo.YiShuoRest;
import com.ly.mpayment.rest.up.yixinyou.YiXinYouRest;
import com.ly.mpayment.rest.up.youxinya.YouXinYaRest;
import com.ly.mpayment.rest.up.yujing.YuJingRest;
import com.ly.mpayment.rest.up.yunchuang.YunChuangRest;
import com.ly.mpayment.rest.up.yunshan.YunShanRest;
import com.ly.mpayment.rest.up.zhaoguo.ZhaoGuoRest;
import com.ly.mpayment.rest.up.zhengbang.ZhengBangRest;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import com.ly.mpayment.core.util.Config;
import com.ly.mpayment.core.util.CookieRedis;
import com.ly.mpayment.persist.service.downrechargeflow.IDownRechargeFlowService;
import com.ly.mpayment.persist.service.downshopinfo.IDownShopInfoService;
import com.ly.mpayment.persist.service.uporder.IUporderService;
import com.ly.mpayment.persist.service.upshopinfo.IUpShopInfoService;
import org.springframework.util.CollectionUtils;

/**
 * 订单轮训处理类
 *
 * @Description: TODO
 * @date Jul 25, 2013 3:01:46 PM
 *
 */
@Service
@Component("autoOrderService")
public class AutoOrderService {

	Logger logger = Logger.getLogger(AutoOrderService.class);

	// 未处理订单
	public static ConcurrentSkipListMap<String, DownRechargeFlow> cons = new ConcurrentSkipListMap<>();
	// 查询订单创建几分钟之后还没有回调的订单更新状态
	public static ConcurrentSkipListMap<String, UpOrder>  upOrders= new ConcurrentSkipListMap<>();
	// 处理提交到上游失败的订单
	public static ConcurrentSkipListMap<String, UpOrder> upOrdersCommitFailt = new ConcurrentSkipListMap<>();
	// 缓存订单
	public static ConcurrentSkipListMap<String, DownRechargeFlow> maintenances = new ConcurrentSkipListMap<>();
	//手动批量提单
	public static BlockingQueue<ManualRechargeOrder> manualOrder = new LinkedBlockingQueue<>();

	@Autowired
	IDownRechargeFlowService flowService;

	@Autowired
	IDownShopInfoService shopService;

	@Autowired
	IUporderService upOrderService;

	@Autowired
	IUpShopInfoService upShopInfoService;

	@Autowired
	private ThreadPoolTaskExecutor taskExecutor;

	private int start = 1;

	@Autowired
	ICallOrderService callOrderService;

	@Autowired
	OrderProcessing orderProcessing;

	@Autowired
	ProductTimerService timerService;

	@Autowired
	ProductTimerUpService timerUpService;

	@Autowired
	HeBaoRest heBaoRest;


	/**
	 * 10秒钟 查询一次失败的订单 来处理
	 *
	 * @Title searchOrderManager
	 * @Description TODO
	 */
	public void searchOrderManager() {
		orderHandler();
	}

	public void orderHandler() {

		if (CookieRedis.get("upOrdersCommitFailt").equals(Config.onOff)) {
			// 处理提交到上游失败的订单
			//处理回调失败的订单
			handlerOrderCommitFailt();
		}


		if (CookieRedis.get("handlerDownOrder").equals(Config.onOff)) {
			// 处理未充值成功的订单 重新匹配
			if (cons.isEmpty()) {
				List<DownRechargeFlow> flows = this.flowService
						.findOrderFail(Integer.valueOf(CookieRedis.get("orderThreadSize")));
				if (flows != null) {
					for (DownRechargeFlow flow : flows) {
						if (this.upOrderService.findByDownFlowIdSql(flow.getDownorderuuid()) == null) {
							cons.put(flow.getDownorderuuid(), flow);
						}
					}
				}
			}
			handlerDownOrder();
		}
		if (CookieRedis.get("handleOrder").equals(Config.onOff)) {
			// 查询订单创建几分钟之后还没有回调的订单更新状态
			if (upOrders.isEmpty()) {
				queryWatingOrder();
			}
			handleOrder();
		}

		if (CookieRedis.get("callResultQueue").equals(Config.onOff)) {
			// 处理下游回调失败订单 回调次数超过三次的不查询
			List<DownRechargeFlow> flows = this.flowService
					.findOrderNotCallFail(Integer.valueOf(CookieRedis.get("orderThreadSize")));
			if (flows != null) {
				if (OrderProcessing.callResultQueue.isEmpty()) {
					for (DownRechargeFlow flow : flows) {
						OrderProcessing.callResultQueue.add(flow);
					}
				}

			}
		}

		// 处理缓存订单
		if (CookieRedis.get("maintenance").equals(Config.onOff)) {
			if (maintenances.isEmpty()) {
				List<DownRechargeFlow> flows = this.flowService
						.findOrderMaintenance(Integer.valueOf(CookieRedis.get("orderThreadSize")));
				if (flows != null) {
					for (DownRechargeFlow flow : flows) {
						if (this.upOrderService.findByDownFlowIdSqlMaintenances(flow.getDownorderuuid()) == null) {
							maintenances.put(flow.getDownorderuuid(), flow);
						}
					}
				}
			}
		}
		// 匹配支付成功的订单主动查询结果

		//分销余额检查

		//供货余额检查

		callOrder();
		timerPrice();
		timerPriceUp();
		//heBaoRest.heartYd(CookieRedis.get("ChinaMobileHeBaoToken"));
		logger.info(String.format(
				"searchOrderManager=cons:%s,upOrders:%s,upOrdersCommitFailt:%s,callResultQueue:%s,maintenances:%s,ActiveCount:%s",
				cons.size(), upOrders.size(), upOrdersCommitFailt.size(), OrderProcessing.callResultQueue.size(),
				maintenances.size(), taskExecutor.getActiveCount()));
	}

	/**
	 * 回调订单30秒执行一次
	 */
	private void callOrder(){
		List<CallOrder> callOrders = callOrderService.findByOrder();
		if(CollectionUtils.isEmpty(callOrders)){
			return;
		}
		for (CallOrder callOrder : callOrders){
			DownRechargeFlow flow = flowService.findById(callOrder.getOrderId());
			if(flow != null){
				orderProcessing.sendResultDownShop(flow,false);
			}

		}
	}

	/**
	 * 定时调价 查询配置表未执行的 配置 执行 并且修改状态
	 */
	private void timerPrice(){
		List<ProductTimer> productTimers = timerService.findExecute(DateUtils.getNowDateYMD());
		if(!CollectionUtils.isEmpty(productTimers)){
			for (ProductTimer timer : productTimers ) {
				if (DateUtils.parseDatetoShortHHmm(timer.getExecuteTime()).equals(DateUtils.parseDatetoShortHHmm(DateUtils.getNowDate()))) {
					logger.info("执行调价_timerPrice:"+timer.getId());
					timerService.executeProductTimer(timer.getId());
				}else{
					logger.info("执行调价_timerPrice_时间未到:"+timer.getId());
				}
			}
		}
	}

	/**
	 * 供货定时调价
	 */
	private void timerPriceUp(){
		List<ProductTimerUp> productTimers = timerUpService.findExecute(DateUtils.getNowDateYMD());
		if(!CollectionUtils.isEmpty(productTimers)){
			for (ProductTimerUp timer : productTimers ) {
				if (DateUtils.parseDatetoShortHHmm(timer.getExecuteTime()).equals(DateUtils.parseDatetoShortHHmm(DateUtils.getNowDate()))) {
					logger.info("执行调价_timerPriceup:"+timer.getId());
					timerUpService.executeProductTimer(timer.getId());
				}else{
					logger.info("执行调价_timerPriceup_时间未到:"+timer.getId());
				}
			}
		}
	}

	/**
	 * 查询等待充值中的订单，超过3分钟的等待充值订单
	 */
	private void queryWatingOrder(){
		List<UpOrder> orders = this.upOrderService.findOrders(
				Integer.valueOf(CookieRedis.get("orderThreadSize")), start,
				Integer.valueOf(CookieRedis.get("minutes")));
		if (!orders.isEmpty()) {
			start++;
		} else {
			start = 0;
			start = start <= 0 ? 0 : start;
		}
		if (orders != null) {
			for (UpOrder order : orders) {
				UpShopInfo shopInfo = upShopInfoService.findByUserId(order.getUserOrder().getUseruuid());
				if(shopInfo.getQuerySwitch()){
					order = this.upOrderService.findById(order.getUporderuuid());
					if (order != null && order.getStatus() == Config.status[0]) {
						// 只处理充值中的订单查询
						upOrders.put(order.getUporderuuid(), order);
					}
				}
			}
		}
	}


	/**
	 * 处理丢单情况下的待充值订单
	 */
	private void handlerDownOrder() {
		NavigableSet<String> navs = cons.descendingKeySet();
		Iterator<String> ites = navs.iterator();
		while (ites.hasNext()) {
			try {
				DownRechargeFlow downFlow = cons.get(ites.next().trim());
				if (downFlow != null) {
					cons.remove(downFlow.getDownorderuuid());
					DownShopInfo shop = this.shopService.findShopInfoByUuid(downFlow.getUserFlow().getUseruuid());
					if (shop != null) {
						logger.info("处理等待充值的订单:" + downFlow.getDownorderuuid() +":"+ downFlow.getDowonphonenum());
						try{
							if (this.upOrderService.findByDownFlowIdSql(downFlow.getDownorderuuid()) == null) {
								downFlow = this.flowService.findById(downFlow.getDownorderuuid());
								RechargeRest.orderQueue.add(downFlow);
								logger.info("添加到充值队列:" + downFlow.getDowonphonenum());
							}

						}catch (Exception e){
							e.printStackTrace();
							logger.info("处理等待充值的订单异常:" + downFlow.getDownorderuuid() +":"+ downFlow.getDowonphonenum());
						}
					}
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		if(upOrders.isEmpty()){
			this.queryWatingOrder();
		}
	}

	/**
	 * 处理下游缓存订单
	 */
	private synchronized void handlerDownOrderMaintenance() {
		NavigableSet<String> navs = maintenances.descendingKeySet();
		Iterator<String> ites = navs.iterator();
		while (ites.hasNext()) {
			try {
				DownRechargeFlow downFlow = maintenances.get(ites.next().trim());
				if (downFlow != null) {
					downFlow = this.flowService.findById(downFlow.getDownorderuuid());
					DownShopInfo shop = this.shopService.findShopInfoByUuid(downFlow.getUserFlow().getUseruuid());
					if (shop != null && downFlow.getStatus() == Config.status[9]) {
						if (shop.getUser().getUserstatus() != Config.productStatus[1]
								|| downFlow.getDownShopProduct().getStatus() != Config.productStatus[1]) {
							logger.info("缓存订单_处理:{},{}" + shop.getDownshopbalance() + downFlow.getDowonphonenum());
							AutoOrderService.maintenances.remove(downFlow.getDownorderuuid());
						} else {
							downFlow.setStatus(Config.status[5]);
							this.flowService.updateDownrechargeflow(downFlow);
							logger.info("处理缓存订单:{},{}" + downFlow.getDownorderuuid() + downFlow.getDowonphonenum());
						}
					}
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}

	/**
	 * 处理提交失败的订单
	 */
	public void handlerOrderCommitFailt() {
//		logger.info("handlerOrderCommitFailt_start:");
//		for(String key : RechargeRest.failtUpOrder.keySet()){
//			UpOrder upOrder = upOrderService.findByIdFail(key);
//			if(upOrder != null && upOrder.getStatus() == Config.status[0]){
//				logger.info("处理提交失败回调的订单:"+upOrder.getUpphonenum());
//				flowService.orderHanlderFailt(upOrder,upOrderService,flowService,shopService,taskExecutor,RechargeRest.failtUpOrder.get(key));
//			}
//		}
//
//		for(String key : RechargeRest.successUpOrder.keySet()){
//			UpOrder upOrder = upOrderService.findByIdFail(key);
//			if(upOrder != null && upOrder.getStatus() == Config.status[0]){
//				logger.info("处理订单成功的订单:"+upOrder.getUpphonenum());
//				flowService.orderHanlder(upOrder,upOrderService,flowService,shopService,taskExecutor,RechargeRest.successUpOrder.get(key));
//			}
//		}
	}



	@Autowired
	private FanXinRest fanXinRest;

	@Autowired
    private ChinaUnicomRest chinaUnicomRest;

	@Autowired
	private ChenHanRest chenHanRest;

	@Autowired
	private ShuWangRest shuWangRest;

	@Autowired
	private GuangMuRest guangMuRest;

	@Autowired
	private QingChiRest qingChiRest;

	@Autowired
	private LongZhangRest longZhangRest;

	@Autowired
	private YuJingRest yuJingRest;

	@Autowired
	private YiTongDaRest yiTongDaRest;

	@Autowired
	private YezhikejiRest yezhikejiRest;

	@Autowired
	private ZhengBangRest zhengBangRest;

	@Autowired
	private MaiYuanRest maiYuanRest;

	@Autowired
	private YouXinYaRest youXinYaRest;

	@Autowired
	private FeiZhiDuRest feiZhiDuRest;

	@Autowired
	private XuanJieRest xuanJieRest;

	@Autowired
	private HongLuRest hongLuRest;

	@Autowired
	private YunChuangRest yunChuangRest;

	@Autowired
	private JiuYaRest jiuYaRest;

	@Autowired
	private WanLiFangHeRest wanLiFangHeRest;

	@Autowired
	private JiaMiDuoRest jiaMiDuoRest;

	@Autowired
	private DongYeRest dongYeRest;

	@Autowired
	private SuHuRest suHuRest;

	@Autowired
	private HuaRongRest huaRongRest;

	@Autowired
	private MeiJiaRest meiJiaRest;

	@Autowired
	private ShouRuanRest shouRuanRest;

	@Autowired
	private MaiYuanhfRest maiYuanhfRest;

	@Autowired
	private FuLuRest fuLuRest;

	@Autowired
	private QingHaiYd qingHaiYd;

	@Autowired
	private JiangRenRest jiangRenRest;

	@Autowired
	private YiShuoRest yiShuoRest;

	@Autowired
	private YunShanRest yunShanRest;

	@Autowired
	private GuoChuangRest guoChuangRest;

	@Autowired
	private NaPiRest naPiRest;

	@Autowired
	private MaiYuan2Rest maiYuan2Rest;

	@Autowired
	private YiXinYouRest yiXinYouRest;

	@Autowired
	private JueShengRest jueShengRest;

	@Autowired
	private HuiSuTongRest huiSuTongRest;

	@Autowired
	private SanChongMaoRest sanChongMaoRest;

	@Autowired
	FengNiuRest fengNiuRest;

	@Autowired
	YingYouRest yingYouRest;

	@Autowired
	MaSiKeRest maSiKeRest;

	@Autowired
	HongShiRest hongShiRest;

	@Autowired
	TianZhongRest tianZhongRest;

	@Autowired
	WswpayRest wswpayRest;

	@Autowired
	RenXingRest renXingRest;

	@Autowired
	AnChangRest anChangRest;

	@Autowired
	private XinJinRest xinJinRest;

	@Autowired
	private QuanGuoLtRest quanGuoLtRest;

	@Autowired
	private ZhaoGuoRest zhaoGuoRest;
	/**
	 * 处理上游订单查询 需要区分
	 */
	private synchronized void handleOrder() {
		if (!upOrders.isEmpty()) {
			NavigableSet<String> ups = upOrders.descendingKeySet();
			Iterator<String> tes = ups.iterator();
			while (tes.hasNext()) {
				try {
					final UpOrder upOrder = upOrders.remove(tes.next().trim());
					UpShopInfo shopInfo = upShopInfoService.findByUserId(upOrder.getUserOrder().getUseruuid());
					if(shopInfo.getQuerySwitch()){
						logger.info("订单查询:"+upOrder.getUpphonenum());
						if (shopInfo != null) {
							switch (shopInfo.getShopnum()) {
//								case Config.fanxin:
//									fanXinRest.queryOrder(upOrder,shopInfo);
//									break;
//                                case Config.chinaunicom:
//                                    chinaUnicomRest.queryOrder(upOrder,shopInfo);
//                                    break;
//								case Config.chenhan:
//									chenHanRest.queryOrder(upOrder,shopInfo);
//									break;
//								case Config.shuwang:
//									shuWangRest.queryOrder(upOrder,shopInfo);
//									break;
								case Config.guangmu:
									guangMuRest.queryOrder(upOrder,shopInfo);
									break;
								case Config.qingchi:
									qingChiRest.queryOrder(upOrder,shopInfo);
									break;
//								case Config.longzhang:
//									longZhangRest.queryOrder(upOrder,shopInfo);
//									break;
//								case Config.yujing:
//									yuJingRest.queryOrder(upOrder,shopInfo);
//									break;
//								case Config.yiche:
//									yiTongDaRest.queryOrder(upOrder,shopInfo);
//									break;
//								case Config.yezhikeji:
//									yezhikejiRest.queryOrder(upOrder,shopInfo);
//									break;
//								case Config.zhengbang:
//									zhengBangRest.queryOrder(upOrder,shopInfo);
//									break;
//								case Config.feizhidu:
//									feiZhiDuRest.queryOrder(upOrder,shopInfo);
//									break;
//								case Config.youxinya:
//									youXinYaRest.queryOrder(upOrder,shopInfo);
//									break;
//								case Config.yuanmai:
//									maiYuanRest.queryOrder(upOrder,shopInfo);
//									break;
//								case Config.xuanjie:
//									xuanJieRest.queryOrder(upOrder,shopInfo);
//									break;
//								case Config.honglu:
//									hongLuRest.queryOrder(upOrder,shopInfo);
//									break;
//								case Config.yunchuang:
//									yunChuangRest.queryOrder(upOrder,shopInfo);
//									break;
//								case Config.jiuya:
//									jiuYaRest.queryOrder(upOrder,shopInfo);
//									break;
//								case Config.wanlifanghe:
//									wanLiFangHeRest.queryOrder(upOrder,shopInfo);
//									break;
//								case Config.jiamiduo:
//									jiaMiDuoRest.queryOrder(upOrder,shopInfo);
//									break;
//								case Config.dongye:
//									dongYeRest.queryOrder(upOrder,shopInfo);
//									break;
								case Config.suhukeji:
									suHuRest.queryOrder(upOrder,shopInfo);
									break;
//								case Config.huarongxunfang:
//									huaRongRest.queryOrder(upOrder,shopInfo);
//									break;
//								case Config.meijia:
//									meiJiaRest.queryOrder(upOrder,shopInfo);
//									break;
//								case Config.shuoruan:
//									shouRuanRest.queryOrder(upOrder,shopInfo);
//									break;
//								case Config.maiyuanhf:
//									maiYuanhfRest.queryOrder(upOrder,shopInfo);
//									break;
//								case Config.fulu:
//									fuLuRest.queryOrder(upOrder,shopInfo);
//									break;
//								case Config.qinghaiyd:
//									qingHaiYd.queryOrder(upOrder,shopInfo);
//									break;
//								case Config.jiangren:
//									jiangRenRest.queryOrder(upOrder,shopInfo);
//									break;
//								case Config.yishuo:
//									yiShuoRest.queryOrder(upOrder,shopInfo);
//									break;
//								case Config.yunshan:
//									yunShanRest.queryOrder(upOrder,shopInfo);
//									break;
//								case Config.guochuang:
//									guoChuangRest.queryOrder(upOrder,shopInfo);
//									break;
//								case Config.napikeji:
//									naPiRest.queryOrder(upOrder,shopInfo);
//									break;
//								case Config.maiyuan2:
//									maiYuan2Rest.queryOrder(upOrder,shopInfo);
//									break;
//								case Config.yixinyou:
//									yiXinYouRest.queryOrder(upOrder,shopInfo);
//									break;
//								case Config.hebao:
//									heBaoRest.queryOrder(upOrder,shopInfo);
//									break;
//								case Config.juesheng:
//									jueShengRest.queryOrder(upOrder,shopInfo);
//									break;
//								case Config.huisutong:
//									huiSuTongRest.queryOrder(upOrder,shopInfo);
//									break;
//								case Config.sanchongmao:
//									sanChongMaoRest.queryOrder(upOrder,shopInfo);
//									break;
//								case Config.fengniu:
//									fengNiuRest.queryOrder(upOrder,shopInfo);
//									break;
//								case Config.yingyou:
//									yingYouRest.queryOrder(upOrder,shopInfo);
//									break;
//								case Config.masike:
//									maSiKeRest.queryOrder(upOrder,shopInfo);
//									break;
//								case Config.hongshi:
//									hongShiRest.queryOrder(upOrder,shopInfo);
//									break;
//								case Config.tianzhong:
//									tianZhongRest.queryOrder(upOrder,shopInfo);
//									break;
//								case Config.wswpay:
//									wswpayRest.queryOrder(upOrder,shopInfo);
//									break;
//								case Config.renxingkeji:
//									renXingRest.queryOrder(upOrder,shopInfo);
//									break;
//								case Config.anchang:
//									anChangRest.queryOrder(upOrder,shopInfo);
//									break;
//								case Config.xinjin:
//									xinJinRest.queryOrder(upOrder,shopInfo);
//									break;
//								case Config.qgliantong:
//									quanGuoLtRest.queryOrder(upOrder,shopInfo);
//									break;
//								case Config.zhaoguo:
//									zhaoGuoRest.queryOrder(upOrder,shopInfo);
//									break;
//								default:
//									logger.info("没有找到渠道:" + upOrder.getUpphonenum());
//									break;
							}
						}
					}
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}
	}

//	/**
//	 *  处理上游回调失败的订单
//	 * @param upOrder
//	 */
//	private void handlerUpMobileOrder(UpOrder upOrder){
//		MobileOrders orders = this.mobileOrderService.findById(upOrder.getUpOrderId());
//		if(orders.getOrderStatus() == 5){
//			flowService.orderHanlderFailt(upOrder, upOrderService, flowService, shopService, taskExecutor, orders.getRemark());
//		}else if(orders.getOrderStatus() == 4){
//			flowService.orderHanlder(upOrder, upOrderService, flowService, shopService, taskExecutor, orders.getRemark());
//		}
//	}

}
